#!/usr/bin/env python3
"""
基于新的bg.png设计更新所有图标
"""

from PIL import Image
import os

def update_all_icon_sizes():
    """基于新的bg.png生成所有尺寸的图标"""
    icons_dir = "/Users/ethan/Codes/longimagereader/icons"

    # 读取新的主图标
    main_icon_path = os.path.join(icons_dir, "app.png")
    if not os.path.exists(main_icon_path):
        print("❌ 错误：找不到主图标文件 app.png")
        return False

    main_icon = Image.open(main_icon_path)
    print(f"✓ 读取主图标: {main_icon.size}")

    # 需要生成的尺寸
    sizes = [16, 32, 48, 64, 128, 256, 512]

    print("开始生成所有尺寸的图标...")

    # 生成各种尺寸
    for size in sizes:
        print(f"生成 {size}x{size} 图标...")

        # 高质量缩放
        if size == main_icon.size[0]:
            icon = main_icon
        else:
            icon = main_icon.resize((size, size), Image.Resampling.LANCZOS)

        filename = f"app_{size}x{size}.png"
        icon.save(os.path.join(icons_dir, filename), "PNG", optimize=True)
        print(f"✓ 生成 {filename}")

    print("\n✅ 所有PNG图标更新完成！")
    return True

if __name__ == "__main__":
    update_all_icon_sizes()